package DynamicProxy;

/**
 * @Author shangchao
 * @Date 2020/9/25 19:55
 */
public class SimpleStaticProxyDemo {
    static interface IService{
        public void sayHello();
    }

    static class RealService implements IService{
        @Override
        public void sayHello() {
            System.out.println("hello");
        }
    }

    static class TraceProxy implements IService{
        private IService realService;

        public TraceProxy(IService realService){
            this.realService = realService;
        }

        @Override
        public void sayHello() {
            System.out.println("entering sayHello");
            realService.sayHello();
            System.out.println("leaving sayHello");
        }
    }

    public static void main(String[] args) {
        IService realService = new RealService();
        IService proxyService = new TraceProxy(realService);
        proxyService.sayHello();
    }
}
